<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //1 准备两个构造函数
        function Father(uname, age) {
            this.uname = uname;
            this.age = age;
        }

        function Son(uname, age, score) {
            Father.call(this,uname,age);//使用call改变父构造的指向达到继承效果
            this.score = score;//可定制子构造的属性
        }

        //2 子对象属性的使用
        var son = new Son('ArimaMisaki',13,100);
        console.log(son);

        //3 子对象方法的使用
        Son.prototype = new Father();//儿子的原型对象是父亲的构造器
        Son.prototype.constructor = Son;//直接覆改原型对象，记得用constructor指回原来的构造函数
        Father.prototype.money = function(){
            console.log(10000);
        };
        Son.prototype.exam = function(){
            console.log('要考试');
        };
        var son2 = new Son('ArimaMisaki',14,99)
        son2.exam();
        son2.money();
    </script>
</body>

</html>